package com.zyq.ssyx.acl.controller;
import com.zyq.ssyx.common.result.CommonResponse;
import com.zyq.ssyx.common.result.ResultCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author clap of thunder
 * @date 2023-11-16 19:31
 * @description
 */

@Api(tags = "登录接口")
@RestController
@RequestMapping("/admin/acl/index")
@CrossOrigin //解决跨域问题的注解（跨域问题：前后端的协议，ip，端口号不一致）
public class IndexController {

//    url: '/admin/acl/index/login',
//    method: 'post'
    @ApiOperation("登录")
    @PostMapping("/login")
    public CommonResponse login(){
        Map<String, String> map = new HashMap<>();
        map.put("admin","admin-token");
        return CommonResponse.ok(map);
//        return CommonResponse.build(map, ResultCodeEnum.SUCCESS);
    }

//    url: '/admin/acl/index/info',
//    method: 'get',
//    params: { token }

    @ApiOperation("获取信息")
    @GetMapping("/info")
    public CommonResponse getInfo(){
        Map<String, String> map = new HashMap<>();
        map.put("name","admin");
        map.put("avater","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        return CommonResponse.build(map, ResultCodeEnum.SUCCESS);
    }

//    url: '/admin/acl/index/logout',
//    method: 'post'

    @ApiOperation("退出登录")
    @PostMapping("/logout")
    public CommonResponse logout(){
        return CommonResponse.build(null, ResultCodeEnum.SUCCESS);
    }
}
